﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>Smart LINKiA - Unit Trace</title>
    <meta name="keywords" content="Smart Link">
    <meta name="description" content="Smart Link">

    <link href="css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="css/font-awesome.css" rel="stylesheet">
    <link href="css/plugins/jQueryUI/jquery-ui-1.10.4.custom.min.css" rel="stylesheet">
    <!-- Data Tables -->
    <link href="css/plugins/jqgrid/ui.jqgrid.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=2.2.0" rel="stylesheet">
    <style>
        /* Additional style to fix warning dialog position */

        #alertmod_table_list_passDetail {
            top: 900px !important;
        }


         #sfLogoFixedLayer {
            position: fixed;
            right: 0px;
            bottom: 0px;
            height: 75px;
            width: 75px;
            z-index: 9999;
        }
    </style>
</head>

<body>
    <div id="sfLogoFixedLayer">
        <img src="img/SFLogoSquareTransparent.png" style="height:75px;width:75px" />
    </div>

    <div id="wrapper">
        <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element" style="text-align: center;">
                            <span>
                                <img alt="image" class="img-circle" src="img/SMARTLINK.png" width="100" height="100" />
                            </span>
                            <a data-toggle="dropdown" class="dropdown-toggle" href="http://172.16.29.188:60/fanuc2en">
                                <span class="clear">
                                    <span class="block m-t-xs">
                                        <strong class="font-bold">Smart LINK</strong>
                                    </span>
                                </span>
                            </a>

                        </div>
                        <div class="logo-element">
                            FANUC
                        </div>
                    </li>
                    <li class="active">
                        <a href="index.html#"><i class="fa fa-table"></i> <span class="nav-label">Trace</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li>
                                <a href="UnitListTraceEN.html">Unit List</a>
                            </li>
                            <li  class="active">
                                <a href="UnitTraceEN.html">Unit Trace</a>
                            </li>

                        </ul>
                    </li>
                    <li>
                        <a href="index.html#"><i class="fa fa-edit"></i> <span class="nav-label">Historic Data</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li>
                                <a href="AlarmHistoryEN.html">Alarm History</a>
                            </li>
                            <li>
                                <a href="RobotStateChangesEN.html">Robot State Changes</a>
                            </li>
                            <li>
                                <a href="ParameterChangesEN.html">Parameter Changes</a>
                            </li>
                        </ul>
                    </li>
                </ul>

            </div>
        </nav>
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                    <div class="navbar-header">
                        <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="UnitTrace.html#"><i class="fa fa-bars"></i> </a>
                        <!--<form role="search" class="navbar-form-custom" method="post" action="search_results.html">
                            <div class="form-group">
                                <input type="text" placeholder="请输入您需要查找的内容 …" class="form-control" name="top-search" id="top-search">
                            </div>
                        </form>-->
                    </div>
                    <ul class="nav navbar-top-links navbar-right">
                        <li>
                                <span class="m-r-sm text-muted welcome-message">
                                    EN
                                    <a href="UnitTrace.html" title="Chinese">CHN</a>
                                    <a href="http://172.16.29.188:60/fanuc2en" title="Home"><i class="fa fa-home"></i></a><strong class="font-bold">Smart LINK
                                    </strong>
                                </span>
                        </li>


                        <li>
                            <a href="login.html">
                                <i class="fa fa-sign-out"></i> Sign Out
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-10">
                    <h2>Unit Trace</h2>
                </div>

            </div>
            <div class="wrapper wrapper-content  animated fadeInRight">
                <div class="row">
                    <div class="col-lg-12">
                        <!-- form -->
                        <div class="ibox float-e-margins">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="titleh">Unit Serial Number Trace</h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content basic-search">
                                <div class="wrapper">
                                    <form class="form-horizontal ng-pristine ng-valid" method="post">
                                        <div class="row">
                                            <div class="col-xs-12">
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <label>Part Serial No：</label>
                                                    </div>
                                                    <div class="col-md-2">
                                                        <input name="partSerial" id="partSerial" class="form-control" type="text" placeholder="Part Serial No" />
                                                    </div>
                                                    <div class="col-md-2">
                                                        <button name="search" class="btn btn-success" onclick="Search()" type="button">Search</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-12">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="titleh">Unit Welding Detail</h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="panel blank-panel">
                                    <div class="panel-heading">
                                        <div class="panel-options">
                                            <ul class="nav nav-tabs">
                                                <li class="active">
                                                    <a aria-expanded="true" href="tabs_panels.html#passDetail" data-toggle="tab">Weld Pass Detail</a>
                                                </li>
                                                <li>
                                                    <a aria-expanded="false" href="tabs_panels.html#unitDetail" data-toggle="tab">Unit Detail</a>
                                                </li>
                                                <li>
                                                    <a aria-expanded="false" href="tabs_panels.html#alarms" data-toggle="tab">Related Alarms</a>
                                                </li>
                                                <li class="">
                                                    <a aria-expanded="false" href="tabs_panels.html#robotStateChanges" data-toggle="tab">Related Robot State Changes</a>
                                                </li>
                                                <li class="">
                                                    <a aria-expanded="false" href="tabs_panels.html#parameterChanges" data-toggle="tab">Related Parameter Changes</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                        <div class="tab-content" style="height:250px">
                                            <div class="tab-pane active" id="passDetail">
                                                <div class="jqGrid_wrapper">
                                                    <table id="table_list_passDetail"></table>
                                                    <div id="pager_list_passDetail"></div>
                                                </div>
                                            </div>
                                            <div class="tab-pane" id="unitDetail">
                                                <div class="jqGrid_wrapper">
                                                    <table id="table_list_unitDetail"></table>
                                                    <div id="pager_list_unitDetail"></div>
                                                </div>
                                            </div>
                                            <div class="tab-pane" id="alarms">
                                                <div class="jqGrid_wrapper">
                                                    <table id="table_list_alarms"></table>
                                                    <div id="pager_list_alarms"></div>
                                                </div>
                                            </div>
                                            <div class="tab-pane" id="robotStateChanges">
                                                <div class="jqGrid_wrapper">
                                                    <table id="table_list_robotStateChanges"></table>
                                                    <div id="pager_list_robotStateChanges"></div>
                                                </div>
                                            </div>
                                            <div class="tab-pane" id="parameterChanges">
                                                <div class="jqGrid_wrapper">
                                                    <table id="table_list_parameterChanges"></table>
                                                    <div id="pager_list_parameterChanges"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                    
                    <div class="col-lg-12" id="Diagramchart1">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="title1"></h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="jqGrid_wrapper">
                                    <div id="Diagram1" style="width: 100%;height:400px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-12" id="Diagramchart2">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="title2"></h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="jqGrid_wrapper">
                                    <div id="Diagram2" style="width: 100%;height:400px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-12" id="Diagramchart3">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="title3"></h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="jqGrid_wrapper">
                                    <div id="Diagram3" style="width: 100%;height:400px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-12" id="Diagramchart4">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="title4"></h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="jqGrid_wrapper">
                                    <div id="Diagram4" style="width: 100%;height:400px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-12" id="Diagramchart5">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="title5"></h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="jqGrid_wrapper">
                                    <div id="Diagram5" style="width: 100%;height:400px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-12" id="Diagramchart6">
                        <div class="ibox ">
                            <div class="ibox-title">
                                <div class="pull-left">
                                    <h5 id="title6"></h5>
                                </div>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div class="jqGrid_wrapper">
                                    <div id="Diagram6" style="width: 100%;height:400px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Mainly scripts -->
    <script src="js/echarts.min.js"></script>
    <script src="js/jquery-2.1.1.min.js"></script>
    <script src="js/bootstrap.min.js?v=3.4.0"></script>
    <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!-- Peity -->
    <script src="js/plugins/peity/jquery.peity.min.js"></script>
    <!-- jqGrid -->
    <script src="js/plugins/jqgrid/i18n/grid.locale-en.js"></script>
    <script src="js/plugins/jqgrid/jquery.jqGrid.min.js"></script>
    <!-- Custom and plugin javascript -->
    <script src="js/hplus.js?v=2.2.0"></script>
    <script src="js/plugins/pace/pace.min.js"></script>
    <script src="js/plugins/jquery-ui/jquery-ui.min.js"></script>
    <script src="js/UnitTraceDiagram.js"></script>
    
    <script>
        function reloadGridDataPassDetail(jsonData) {
            $("#table_list_passDetail").jqGrid('clearGridData');
            $("#table_list_passDetail").jqGrid('setGridParam', { data: jsonData }
            ).trigger("reloadGrid");
        }
    </script>
    <!--Reload JqGrid Data Table Unit Detail-->
    <script>
        function reloadGridDataUnitDetail(jsonData) {
            $("#table_list_unitDetail").jqGrid('clearGridData');
            $("#table_list_unitDetail").jqGrid('setGridParam', { data: jsonData }
            ).trigger("reloadGrid");
        }
    </script>
    <!--Reload JqGrid Data Table Alarms-->
    <script>
        function reloadGridDataAlarms(jsonData) {
            $("#table_list_alarms").jqGrid('clearGridData');
            $("#table_list_alarms").jqGrid('setGridParam', { data: jsonData }
            ).trigger("reloadGrid");
        }
    </script>
    <!--Reload JqGrid Data Table Robot State Changes-->
    <script>
        function reloadGridDataRobotStateChanges(jsonData) {
            $("#table_list_robotStateChanges").jqGrid('clearGridData');
            $("#table_list_robotStateChanges").jqGrid('setGridParam', { data: jsonData }
            ).trigger("reloadGrid");
        }
    </script>
    <!--Reload JqGrid Data Table Parameter Changes-->
    <script>
        function reloadGridDataParameterChanges(jsonData) {
            $("#table_list_parameterChanges").jqGrid('clearGridData');
            $("#table_list_parameterChanges").jqGrid('setGridParam', { data: jsonData }
            ).trigger("reloadGrid");
        }
    </script>
    <!--Search Button Clicked-->
    <script>
        function Search() {
            //pass detail
            var url = "api/UnitTrace/" + $("#partSerial").val();
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    if (json == null) {
                        window.alert("No Data Found");
                        reloadGridDataPassDetail();
                        reloadGridDataUnitDetail();
                        reloadGridDataAlarms();
                        reloadGridDataRobotStateChanges();
                        reloadGridDataParameterChanges();
                        refreshChart(1);
                        return;
                    }
                    LoadUnitTrace(json, 1);
                    //alert(json);
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                    //alert(xmlhttprequest.status);
                    //alert(xmlhttprequest.readystate);
                    //alert(textstatus);
                }
            });

            //unit detail
            var model = {
                "PageIndex": 0, "PageSize": 30,
                "PartSerial": $("#partSerial").val()
            }
            var url = "api/UnitListTrace";
            $.ajax({
                type: "post",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                data: model,
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    reloadGridDataUnitDetail(json.TableData);
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                }
            });

            //alarms
            var url = "api/Alarm_History?partSerial=" + $("#partSerial").val() + "&hours=4";
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    reloadGridDataAlarms(json.AlarmRecords);
                    //alert(json);
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                    //alert(xmlhttprequest.status);
                    //alert(xmlhttprequest.readystate);
                    //alert(textstatus);
                }
            });
            //robotStateChanges
            var url = "api/Robot_State_Changes?partSerial=" + $("#partSerial").val() + "&hours=4";
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    reloadGridDataRobotStateChanges(json.RobotStateChangeRecords);
                    //alert(json);
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                    //alert(xmlhttprequest.status);
                    //alert(xmlhttprequest.readystate);
                    //alert(textstatus);
                }
            });
            //parameterChanges
            var url = "api/Parameter_Version?partSerial=" + $("#partSerial").val() + "&hours=4";
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    reloadGridDataParameterChanges(json.ParameterChangeRecords);
                    //alert(json);
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                    //alert(xmlhttprequest.status);
                    //alert(xmlhttprequest.readystate);
                    //alert(textstatus);
                }
            });
        }

        //根据序列号查询
        function LoadUnitTrace(data, flag) {
            //debugger;
            jQuery("#table_list_passDetail").GridUnload();
            ///alert(data.SpotTableData);
            //点焊
            if (data.SpotTableData != null) {
                //fillDataTablePassDetail();
                //给jqGrid重新绑定列
                $("#table_list_passDetail").jqGrid({
                    onSelectRow: function (id) {
                        spotwelding(id);
                        //alert(id);
                    },
                    data: data,
                    datatype: "local",
                    height: 150,
                    width: $('#passDetail').width(),
                    autowidth: true,
                    shrinkToFit: false,
                    rowNum: 20,
                    rowList: [10, 20, 30],
                    colNames: ['工件序列号', '焊缝号', '开始时间', '结束时间', '板厚', '设定压力', '设定电流', '设定电阻', '步增计数', '步增电流', '步增器号'],
                    colModel: [{
                        name: 'Part_Serial', index: 'Part_Serial', width: 100
                    }, {
                        name: 'Pass_No', index: 'Pass_No', width: 100
                    }, {
                        name: 'StartTime', index: 'StartTime', width: 150
                    }, {
                        name: 'EndTime', index: 'EndTime', width: 150
                    }, {
                        name: 'PlateThickness', index: 'PlateThickness', width: 100
                    }, {
                        name: 'StandardStress', index: 'StandardStress', width: 100
                    }, {
                        name: 'StandardCurrent', index: 'StandardCurrent', width: 100
                    }, {
                        name: 'StandardResistence', index: 'StandardResistence', width: 100
                    }, {
                        name: 'StepCount', index: 'StepCount', width: 100
                    }, {
                        name: 'StepCurrent', index: 'StepCurrent', width: 100
                    }, {
                        name: 'SteperNumber', index: 'SteperNumber', width: 100
                    }],
                    data: data.SpotTableData.PointsData,
                    pager: '#pager_list_passDetail',
                    caption: '点焊详细',
                    viewrecords: true,
                    add: false,
                    edit: false,
                    addtext: 'Add',
                    edittext: 'Edit',
                    hidegrid: false
                });
                //jQuery('#table_list_passDetail').trigger('reloadGrid');
                reloadGridDataPassDetail(data.SpotTableData.PointsData);
            }
                //涂胶
            else if (data.SealTableData != null) {
                //fillDataTablePassDetail();
                //给jqGrid重新绑定列
                $("#table_list_passDetail").jqGrid({
                    onSelectRow: function (id) {
                        sealwelding(id);
                        //alert(id);
                    },
                    data: data,
                    datatype: "local",
                    height: 150,
                    width: $('#passDetail').width(),
                    autowidth: true,
                    shrinkToFit: false,
                    rowNum: 20,
                    rowList: [10, 20, 30],
                    colNames: ['工件序列号', '胶条号', '开始时间', '结束时间', '设定温度', '上限压力', '下限压力','总出胶量','胶条直径'],
                    colModel: [{
                        name: 'Part_Serial', index: 'Part_Serial', width: 100
                    }, {
                        name: 'Pass_No', index: 'Pass_No', width: 100
                    }, {
                        name: 'Start_Time', index: 'Start_Time', width: 150
                    }, {
                        name: 'End_Time', index: 'End_Time', width: 150
                    }, {
                        name: 'StandardTemperature', index: 'StandardTemperature', width: 100
                    }, {
                        name: 'MaxTorque', index: 'MaxTorque', width: 100
                    }, {
                        name: 'MinTorque', index: 'MinTorque', width: 100
                    }, {
                        name: 'TotalThroughput', index: 'TotalThroughput', width: 100
                    }, {
                        name: 'Seal_Amount', index: 'Seal_Amount', width: 100
                    }],
                    data: data.SealTableData.PointsData,
                    pager: '#pager_list_passDetail',
                    caption: '涂胶详细',
                    viewrecords: true,
                    add: false,
                    edit: false,
                    addtext: 'Add',
                    edittext: 'Edit',
                    hidegrid: false
                });
                jQuery('#table_list_passDetail').trigger('reloadGrid');
            }
                //打磨
            else if (data.PolishTableData != null) {
                // fillDataTablePassDetail();
                //给jqGrid重新绑定列
                $("#table_list_passDetail").jqGrid({
                    onSelectRow: function (id) {
                        polishwelding(id);
                        //alert(id);
                    },
                    data: data,
                    datatype: "local",
                    height: 150,
                    width: $('#passDetail').width(),
                    autowidth: true,
                    shrinkToFit: false,
                    rowNum: 20,
                    rowList: [10, 20, 30],
                    colNames: ['工件序列号', '开始时间', '结束时间', 'J1电流允许值', 'J2电流允许值', 'J3电流允许值', 'J4电流允许值', 'J5电流允许值', 'J6电流允许值', ],
                    colModel: [{
                        name: 'Part_Serial', index: 'Part_Serial', width: 100
                    }, {
                        name: 'Start_Time', index: 'Start_Time', width: 150
                    }, {
                        name: 'End_Time', index: 'End_Time', width: 150
                    }, {
                        name: 'J1CurrentUSL', index: 'J1CurrentUSL', width: 100
                    }, {
                        name: 'J2CurrentUSL', index: 'J2CurrentUSL', width: 100
                    }, {
                        name: 'J3CurrentUSL', index: 'J3CurrentUSL', width: 100
                    }, {
                        name: 'J4CurrentUSL', index: 'J4CurrentUSL', width: 100
                    }, {
                        name: 'J5CurrentUSL', index: 'J5CurrentUSL', width: 100
                    }, {
                        name: 'J6CurrentUSL', index: 'J6CurrentUSL', width: 100
                    }],
                    data: data.PolishTableData.PointsData,
                    pager: '#pager_list_passDetail',
                    caption: '打磨详细',
                    viewrecords: true,
                    add: false,
                    edit: false,
                    addtext: 'Add',
                    edittext: 'Edit',
                    hidegrid: false
                });
                jQuery('#table_list_passDetail').trigger('reloadGrid');
            }
                //冲压
            else if (data.PressTableData != null) {
                // fillDataTablePassDetail();
                //给jqGrid重新绑定列
                $("#table_list_passDetail").jqGrid({
                    onSelectRow: function (id) {
                        presswelding(id);
                        //alert(id);
                    },
                    data: data,
                    datatype: "local",
                    height: 150,
                    width: $('#passDetail').width(),
                    autowidth: true,
                    shrinkToFit: false,
                    rowNum: 20,
                    rowList: [10, 20, 30],
                    colNames: ['工件序列号', '开始时间', '结束时间', 'J1电流设定值', 'J2电流设定值', 'J3电流设定值', 'J4电流设定值', 'J5电流设定值', 'J6电流设定值','节拍' ],
                    colModel: [{
                        name: 'Part_Serial', index: 'Part_Serial', width: 100
                    }, {
                        name: 'Start_Time', index: 'Start_Time', width: 150
                    }, {
                        name: 'End_Time', index: 'End_Time', width: 150
                    }, {
                        name: 'J1CurrentUSL', index: 'J1CurrentUSL', width: 100
                    }, {
                        name: 'J2CurrentUSL', index: 'J2CurrentUSL', width: 100
                    }, {
                        name: 'J3CurrentUSL', index: 'J3CurrentUSL', width: 100
                    }, {
                        name: 'J4CurrentUSL', index: 'J4CurrentUSL', width: 100
                    }, {
                        name: 'J5CurrentUSL', index: 'J5CurrentUSL', width: 100
                    }, {
                        name: 'J6CurrentUSL', index: 'J6CurrentUSL', width: 100
                    }, {
                        name: 'Beat', index: 'Beat', width: 100
                    }],
                    data: data.PressTableData.PointsData,
                    pager: '#pager_list_passDetail',
                    caption: '冲压详细',
                    viewrecords: true,
                    add: false,
                    edit: false,
                    addtext: 'Add',
                    edittext: 'Edit',
                    hidegrid: false
                });
                jQuery('#table_list_passDetail').trigger('reloadGrid');
            }
            else if (data.ArcWeldingTableData != null) {
                fillDataTablePassDetail();
                //弧焊不用修改
                reloadGridDataPassDetail(data.ArcWeldingTableData.PassData);
            }
            else {
                alert('未找打此序列号相关的焊接,涂胶,打磨,冲压数据.');
            }
        }
    </script>


    <!--JqGrid Formatter-->
    <script>
        function formatQualityGrade(cellvalue, options, rowObject) {
            if (cellvalue == "NG") {
                return "<span style=\"color:red\">" + cellvalue + "</span>";
            }
            else if (cellvalue == "Good") {
                return "<span style=\"color:green\">" + cellvalue + "</span>";
            }
            else if (cellvalue == "OK") {
                return "<span style=\"color:orange\">" + cellvalue + "</span>";
            }
            else {
                return "<span style=\"color:grey\">" + cellvalue + "</span>";
            }
        }

        //function formatPassNo(cellvalue, options, rowObject) {
        //    return "<a onClick='refreshData()'>" + cellvalue + "</a>";
        //}
    </script>
    <!--Fill DataTable Pass Detail-->
    <script>
        function fillDataTablePassDetail(mydata) {

            ////jqGrid pass detail
            // Configuration for jqGrid pass detail
            $("#table_list_passDetail").jqGrid({
                onSelectRow: function (id) {
                    refreshChart(id);
                    //alert(id);
                },
                data: mydata,
                datatype: "local",
                height: 150,
                width: $('#passDetail').width(),
                autowidth: true,
                shrinkToFit: false,
                rowNum: 20,
                rowList: [10, 20, 30],
                colNames: ['Pass No'/*, 'Quality Grade'*/, 'Standard Voltage', 'Voltage USL', 'Voltage LSL', 'Standard Current', 'Current USL', 'Current LSL', 'Setting Voltage(V)', 'Setting Current(A)', 'Speed(cm/min)', 'Frequency(Hz)', 'AMP(mm)', 'Right Weave', 'Left Weave', 'Start Time', 'End Time', 'Insert Time'],
                colModel: [
                    {
                        name: 'PassNo',
                        index: 'PassNo',
                        editable: false,
                        //width: 20,
                        sorttype: "int",
                        search: true,
                        //formatter: formatPassNo
                    },

                    {
                        name: 'VoltageStandard',
                        index: 'VoltageStandard',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'VoltageUSL',
                        index: 'VoltageUSL',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'VoltageLSL',
                        index: 'VoltageLSL',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'CurrentStandard',
                        index: 'CurrentStandard',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'CurrentUSL',
                        index: 'CurrentUSL',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'CurrentLSL',
                        index: 'CurrentLSL',
                        editable: false,
                        //width: 50,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'Voltage',
                        index: 'Voltage',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'Current',
                        index: 'Current',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'Speed',
                        index: 'Speed',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'Frequency',
                        index: 'Frequency',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'Amp',
                        index: 'Amp',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'DwellR',
                        index: 'DewellR',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'DwellL',
                        index: 'DewellL',
                        editable: false,
                        //width: 40,
                        sorttype: "decimal",
                        search: true
                    },
                    {
                        name: 'StartTime',
                        index: 'StartTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },
                    {
                        name: 'EndTime',
                        index: 'EndTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },
                    {
                        name: 'InsertTime',
                        index: 'InsertTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },
                ],
                pager: "#pager_list_passDetail",
                viewrecords: true,
                caption: "Weld Pass",
                add: false,
                edit: false,
                addtext: 'Add',
                edittext: 'Edit',
                hidegrid: false
            });
            // Add selection
            //$("#table_list_passDetail").setSelection(4, true);
            // Setup buttons
            $("#table_list_passDetail").jqGrid('navGrid', '#pager_list_passDetail', {
                edit: false,
                add: false,
                del: false,
                search: true
            }, {
                height: 400,
                reloadAfterSubmit: false
            });

            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_passDetail').setGridWidth(width);
            });
        };
    </script>
    <!--Fill DataTable Unit Detail-->
    <script>
        function fillDataTableUnitDetail(mydata) {
            $("#table_list_unitDetail").jqGrid({
                data: mydata,
                datatype: "local",
                height: 150,
                autowidth: true,
                shrinkToFit: true,
                rowNum: 20,
                rowList: [10, 20, 30],
                colNames: ['ID', 'Part Serial No'/*, 'Quality Grade'*/, 'Batch No', 'Robot YH No', 'Station No', 'Part Name', 'Start Time', 'End Time', 'Insert Time'],
                colModel: [
                    {
                        name: 'Id',
                        index: 'Id',
                        editable: false,
                        //width: 20,
                        sorttype: "int",
                        search: true
                    },
                    {
                        name: 'PartSerial',
                        index: 'PartSerial',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true,
                    },
                    //{
                    //    name: 'QualityGrade',
                    //    index: 'QualityGrade',
                    //    editable: false,
                    //    //width: 30,
                    //    sorttype: "string",
                    //    search: true,
                    //    formatter: formatQualityGrade
                    //},
                    {
                        name: 'BatchNo',
                        index: 'BatchNo',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true
                    },
                    {
                        name: 'RobotNo',
                        index: 'RobotNo',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true
                    },
                    {
                        name: 'StationNo',
                        index: 'StationNo',
                        editable: false,
                        //width: 30,
                        sorttype: "string",
                        search: true
                    },
                    {
                        name: 'PartName',
                        index: 'PartName',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true
                    },
                    {
                        name: 'StartTime',
                        index: 'StartTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },
                    {
                        name: 'EndTime',
                        index: 'EndTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },
                    {
                        name: 'InsertTime',
                        index: 'InsertTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },
                ],
                pager: "#pager_list_unitDetail",
                viewrecords: true,
                caption: "Unit List",
                add: false,
                edit: false,
                addtext: 'Add',
                edittext: 'Edit',
                hidegrid: false
            });

            // Add selection
            //$("#table_list_unitDetail").setSelection(4, true);

            // Setup buttons
            $("#table_list_unitDetail").jqGrid('navGrid', '#pager_list_unitDetail', {
                edit: false,
                add: false,
                del: false,
                search: true
            }, {
                height: 400,
                reloadAfterSubmit: false
            });

            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_unitDetail').setGridWidth(width);
            });
        };
    </script>
    <!--Fill DataTable Alarms-->
    <script>
        function fillDataTableAlarms(mydata) {
            $("#table_list_alarms").jqGrid({
                data: mydata,
                datatype: "local",
                height: 150,
                autowidth: true,
                shrinkToFit: true,
                rowNum: 20,
                rowList: [10, 20, 30],
                colNames: ['ID', 'Robot YH No', 'Alarm Code', 'Alarm Message', 'Alarm Severity', 'Alarm Cause', 'Time'],
                colModel: [
                    {
                        name: 'ID',
                        index: 'ID',
                        editable: false,
                        //width: 20,
                        sorttype: "int",
                        search: true
                    },
                    {
                        name: 'Robot_YH_No',
                        index: 'Robot_YH_No',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'Alarm_Code',
                        index: 'Alarm_Code',
                        editable: false,
                        //width: 30,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'Alarm_Message',
                        index: 'Alarm_Message',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true
                    },
                    {
                        name: 'Alarm_Severity',
                        index: 'Alarm_Severity',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true
                    },
                    {
                        name: 'Alarm_Cause',
                        index: 'Alarm_Cause',
                        editable: false,
                        //width: 30,
                        sorttype: "string",
                        search: true
                    },

                    {
                        name: 'Time',
                        index: 'Time',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },

                ],
                pager: "#pager_list_alarms",
                viewrecords: true,
                caption: "Related Alarms",
                add: false,
                edit: false,
                addtext: 'Add',
                edittext: 'Edit',
                hidegrid: false
            });

            // Add selection
            //$("#table_list_unitDetail").setSelection(4, true);

            // Setup buttons
            $("#table_list_alarms").jqGrid('navGrid', '#pager_list_alarms', {
                edit: false,
                add: false,
                del: false,
                search: true
            }, {
                height: 400,
                reloadAfterSubmit: false
            });

            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_alarms').setGridWidth(width);
            });
        };
    </script>
    <!--Fill DataTable Robot State Changes-->
    <script>
        function fillDataTableRobotStateChanges(mydata) {
            $("#table_list_robotStateChanges").jqGrid({
                data: mydata,
                datatype: "local",
                height: 150,
                autowidth: true,
                shrinkToFit: true,
                rowNum: 20,
                rowList: [10, 20, 30],
                colNames: ['ID', 'Robot YH No', 'Original State', 'Changed State','Change Time'],
                colModel: [
                    {
                        name: 'ID',
                        index: 'ID',
                        editable: false,
                        //width: 20,
                        sorttype: "int",
                        search: true
                    },
                    {
                        name: 'Robot_YH_NO',
                        index: 'Robot_YH_NO',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'Original_State_Type',
                        index: 'Original_State_Type',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'Changed_State_Type',
                        index: 'Changed_State_Type',
                        editable: false,
                        //width: 30,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'ChangeDateTime',
                        index: 'ChangeDateTime',
                        editable: false,
                        //width: 90,
                        sorttype: "date",
                        formater: "datetime",
                        search: true
                    },

                ],
                pager: "#pager_list_robotStateChanges",
                viewrecords: true,
                caption: "Related Robot Changes",
                add: false,
                edit: false,
                addtext: 'Add',
                edittext: 'Edit',
                hidegrid: false
            });

            // Add selection
            //$("#table_list_unitDetail").setSelection(4, true);

            // Setup buttons
            $("#table_list_robotStateChanges").jqGrid('navGrid', '#pager_list_robotStateChanges', {
                edit: false,
                add: false,
                del: false,
                search: true
            }, {
                height: 400,
                reloadAfterSubmit: false
            });

            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_robotStateChanges').setGridWidth(width);
            });
        };
    </script>
    <!--Fill DataTable Parameter Changes-->
    <script>
        function fillDataTableParameterChanges(mydata) {
            $("#table_list_parameterChanges").jqGrid({
                data: mydata,
                datatype: "local",
                height: 150,

                autowidth: true,
                shrinkToFit: true,
                rowNum: 20,
                rowList: [10, 20, 30],
                colNames: ['ID', 'Robot YH No', 'Version', 'Changed Time', 'State', 'Checked By'],
                colModel: [
                    {
                        name: 'ID',
                        index: 'ID',
                        editable: false,
                        //width: 20,
                        sorttype: "int",
                        search: true
                    },
                    {
                        name: 'Robot_YH_No',
                        index: 'Robot_YH_No',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'Version_No',
                        index: 'Version_No',
                        editable: false,
                        //width: 50,
                        sorttype: "string",
                        search: true,
                    },
                    {
                        name: 'Para_Update_Time',
                        index: 'Para_Update_Time',
                        editable: false,
                        //width: 30,
                        sorttype: "date",
                        formater: "datetime",
                        search: true,
                    },
                    {
                        name: 'State',
                        index: 'State',
                        editable: false,
                        //width: 90,
                        sorttype: "bool",
                        search: true
                    },
                    {
                        name: 'Checked_By',
                        index: 'Checked_By',
                        editable: false,
                        //width: 30,
                        sorttype: "string",
                        search: true,
                    },
                ],
                pager: "#pager_list_parameterChanges",
                viewrecords: true,
                caption: "Related Parameter Changes",
                add: false,
                edit: false,
                addtext: 'Add',
                edittext: 'Edit',
                hidegrid: false
            });

            // Add selection
            //$("#table_list_unitDetail").setSelection(4, true);

            // Setup buttons
            $("#table_list_parameterChanges").jqGrid('navGrid', '#pager_list_parameterChanges', {
                edit: false,
                add: false,
                del: false,
                search: true
            }, {
                height: 400,
                reloadAfterSubmit: false
            });

            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_parameterChanges').setGridWidth(width);
            });
        };
    </script>
    <!--ECharts-->
   

    <!--JQGrid Click Event-->>
    <script>
        function refreshChart(id) {

            showordisplaybydiv(2);
            var url = "api/UnitMeasurementHistory?Part_Serial=" + $('#partSerial').val() + "&Pass_No=" + id;

            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    if (json.OnePassMeasurementRecord.Current_TimePoint.length<=1) {
                        myChart.clear();
                        myChart2.clear();
                        return;
                    }
                    var optionCurrent = {
                        title: {
                            text: 'Current'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        toolbox: {
                            feature: {
                                dataView: { show: true, readOnly: false },
                                magicType: { show: true, type: ['line', 'bar'] },
                                restore: { show: true },
                                saveAsImage: { show: true }
                            }
                        },
                        // legend: {
                        //     data: ['标准电压', '电压']
                        // },
                        xAxis: [
                            {
                                type: 'category',
                                show: true,
                                data: json.OnePassMeasurementRecord.Current_TimePoint
                            }
                        ],
                        yAxis: [{
                            type: 'value',
                            // name: 'anpei',
                            // min: 0,
                            // max: 25,
                            position: 'left',
                            boundaryGap:['30%','30%'],
                            axisLabel: {
                                formatter: '{value} A'
                            }
                        },
                        {
                            type: 'value',
                            name: '(A)',
                            show: true,
                            position: 'left',
                            boundaryGap: ['30%', '30%'],
                            // min: 0,
                            // max: 30000,
                            axisLabel: {
                                formatter: '{value} A'
                            }
                        }, {
                            type: 'value',
                            show: false,
                            position: 'right',
                            boundaryGap: ['30%', '30%'],
                            name: '(A)',
                            axisLabel: {
                                formatter: '{value} A'
                            }
                        }
                        ],
                        visualMap: {
                            bottom: 20,
                            right: 0,
                            pieces: [{
                                gt: 0,
                                lte: json.OnePassMeasurementRecord.Standard_Current_LSL,
                                color: '#ff9933'
                            }, {
                                gt: json.OnePassMeasurementRecord.Standard_Current_LSL,
                                lte: json.OnePassMeasurementRecord.Standard_Current_AVGLine,
                                color: '#096'
                            }, {
                                gt: json.OnePassMeasurementRecord.Standard_Current_AVGLine,
                                lte: json.OnePassMeasurementRecord.Standard_Current_USL,
                                color: '#096'
                            }, {
                                gt: json.OnePassMeasurementRecord.Standard_Current_USL,
                                color: '#cc0033'
                            }
                            ],
                            outOfRange: {
                                color: '#999'
                            }
                        },
                        dataZoom: [{
                            type: 'inside',
                            start: 0,
                            end: 100
                        }],
                        series: [

                            {
                                name: 'Current',
                                type: 'line',
                                yAxisIndex: 1,
                                data: json.OnePassMeasurementRecord.Data_Current,
                                markPoint: {
                                    data: [
                                        { type: 'max', name: 'USL', symbol: 'diamond' },
                                        { type: 'min', name: 'LSL', symbol: 'arrow' }
                                    ]
                                },
                                markLine: {
                                    silent: true,
                                    data: [{
                                        yAxis: json.OnePassMeasurementRecord.Standard_Current_LSL
                                    },
                                    {
                                        yAxis: json.OnePassMeasurementRecord.Standard_Current_AVGLine
                                    }, {
                                        yAxis: json.OnePassMeasurementRecord.Standard_Current_USL
                                    }
                                    ]
                                }
                            }]
                    };
                    myChart.setOption(optionCurrent);

                    ///////////////////////////////////////////////////
                    var optionVoltage = {
                        title: {
                            text: 'Voltage'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        toolbox: {
                            feature: {
                                dataView: { show: true, readOnly: false },
                                magicType: { show: true, type: ['line', 'bar'] },
                                restore: { show: true },
                                saveAsImage: { show: true }
                            }
                        },
                        // legend: {
                        //     data: ['标准电压', '电压']
                        // },
                        xAxis: [
                            {
                                type: 'category',
                                show: true,
                                data: json.OnePassMeasurementRecord.Voltage_TimePoint,
                            }
                        ],
                        yAxis: [{
                            type: 'value',
                            // name: 'anpei',
                            // min: 0,
                            // max: 25,
                            position: 'left',
                            boundaryGap: ['30%', '30%'],
                            axisLabel: {
                                formatter: '{value} V'
                            }
                        },
                        {
                            type: 'value',
                            name: 'Voltage',
                            show: true,
                            position: 'left',
                            boundaryGap: ['30%', '30%'],
                            // min: 0,
                            // max: 30000,
                            axisLabel: {
                                formatter: '{value} V'
                            }
                        }, {
                            type: 'value',
                            show: false,
                            position: 'right',
                            boundaryGap: ['30%', '30%'],
                            name: '(V)',
                            axisLabel: {
                                formatter: '{value} V'
                            }
                        }
                        ],
                        visualMap: {
                            bottom: 20,
                            right: 0,
                            pieces: [{
                                gt: 0,
                                lte: json.OnePassMeasurementRecord.Standard_Voltage_LSL,
                                color: '#ffde33'
                            }, {
                                gt: json.OnePassMeasurementRecord.Standard_Voltage_LSL,
                                lte: json.OnePassMeasurementRecord.Standard_Voltage_AVGLine,
                                color: '#096'
                            }, {
                                gt: json.OnePassMeasurementRecord.Standard_Voltage_AVGLine,
                                lte: json.OnePassMeasurementRecord.Standard_Voltage_USL,
                                color: '#096'
                            }, {
                                gt: json.OnePassMeasurementRecord.Standard_Voltage_USL,
                                color: '#cc0033'
                            }],
                            outOfRange: {
                                color: '#999'
                            }
                        },
                        dataZoom: [{
                            type: 'inside',
                            start: 0,
                            end: 100
                        }],
                        series: [

                            {
                                name: 'Voltage',
                                type: 'line',
                                yAxisIndex: 1,
                                data: json.OnePassMeasurementRecord.Data_Voltage,
                                markPoint: {
                                    data: [
                                        { type: 'max', name: 'USL', symbol: 'diamond' },
                                        { type: 'min', name: 'LSL', symbol: 'arrow' }
                                    ]
                                },
                                markLine: {
                                    silent: true,
                                    data: [{
                                        yAxis: json.OnePassMeasurementRecord.Standard_Voltage_LSL
                                    },
                                    {
                                        yAxis: json.OnePassMeasurementRecord.Standard_Voltage_AVGLine
                                    }, {
                                        yAxis: json.OnePassMeasurementRecord.Standard_Voltage_USL
                                    }
                                    ]
                                }
                            }]
                    };
                    myChart2.setOption(optionVoltage);
                }
            })

        }
    </script>


    <!--Page ready first load JS to get last serial number pass detail-->
    <script>
        if (window.location.href.split("=").length >= 2) {
            var partSerial = window.location.href.split("=")[1];
            $('#partSerial').val(partSerial);
            var url = "api/UnitTrace/" + partSerial;
            $.ajax({
                type: "get",
                async: false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    fillDataTablePassDetail();
                    reloadGridDataPassDetail(json.PassData);
                    //alert(json);
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                    //alert(xmlhttprequest.status);
                    //alert(xmlhttprequest.readystate);
                    //alert(textstatus);
                }
            });
        }
        else {
            var url = "api/UnitTrace";
            //Get pass detail
            $(document).ready(
                //fillDataTablePassDetail()
                $.ajax({
                    type: "get",
                    async: false,
                    contenttype: "applicaton/json;charset=utf-8",
                    url: url,
                    datatype: 'json',
                    success: function (json) {
                        //var obj = eval(json);
                        //var totalPages = json.TotalPages;
                        //$(".ui-paging-info").text(totalPages);
                        $('#partSerial').val(json.PartSerial);
                        fillDataTablePassDetail();
                        reloadGridDataPassDetail(json.PassData);
                        //$("#txtid").val("OK");
                    },
                    error: function (xmlhttprequest, textstatus, errorthrown) {
                    }
                })
            );
        }

    </script>
    <!--Page ready then get last serial number unit detail-->
    <script>
        var model = {
            "PageIndex": 0, "PageSize": 30,
            "PartSerial": $("#partSerial").val()
        }
        var url = "api/UnitListTrace";
        $(document).ready(
            $.ajax({
                type: "post",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                data: model,
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    fillDataTableUnitDetail();
                    reloadGridDataUnitDetail(json.TableData);
                    //$("#txtid").val("OK");
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                }
            }));
    </script>

    <!--Page ready then get last serial number alarms-->
    <script>
        var url = "api/Alarm_History?partSerial=" + $("#partSerial").val() + "&hours=4";
        $(document).ready(
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    fillDataTableAlarms();
                    reloadGridDataAlarms(json.AlarmRecords);
                    //$("#txtid").val("OK");
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                }
            }));
    </script>

    <!--Page ready then get last serial number robot state changes-->
    <script>
        var url = "api/Robot_State_Change_History?partSerial=" + $("#partSerial").val() + "&hours=4";
        $(document).ready(
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    fillDataTableRobotStateChanges();
                    reloadGridDataRobotStateChanges(json.RobotStateChangeRecords);
                    //$("#txtid").val("OK");
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                }
            }));
    </script>

    <!--Page ready then get last serial number parameter changes-->
    <script>
        var url = "api/Parameter_Version?partSerial=" + $("#partSerial").val() + "&hours=4";
        $(document).ready(
            $.ajax({
                type: "get",
                //async:false,
                contenttype: "applicaton/json;charset=utf-8",
                url: url,
                datatype: 'json',
                success: function (json) {
                    //var obj = eval(json);
                    //var totalPages = json.TotalPages;
                    //$(".ui-paging-info").text(totalPages);
                    fillDataTableParameterChanges();
                    reloadGridDataParameterChanges(json.ParameterChangeRecords);
                    //$("#txtid").val("OK");
                },
                error: function (xmlhttprequest, textstatus, errorthrown) {
                }
            }));
    </script>
</body>

</html>